#include <jni.h>
#include <string>
#include <android/log.h>

#ifndef LOG_TAG
#define LOG_TAG "Android_NDK"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG ,__VA_ARGS__) // 定义LOGD类型
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG ,__VA_ARGS__) // 定义LOGI类型
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG ,__VA_ARGS__) // 定义LOGW类型
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG ,__VA_ARGS__) // 定义LOGE类型
#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,LOG_TAG ,__VA_ARGS__) // 定义LOGF类型
#endif

//指定以"C"的方式来实现native函数
extern "C"
//JNIEXPORT 宏定义，用于指定该函数是JNI函数
//jobject thiz 表示java native方法所在类的实例
JNIEXPORT jstring JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeString(JNIEnv *env, jobject thiz, jstring content) {
    std::string hello = "this is from C";
    LOGD("Java_com_jzqf_ndk_jni_Ndk_getTypeString");
    return (*env).NewStringUTF(hello.c_str());
}
extern "C"
JNIEXPORT jboolean JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeBoolean(JNIEnv *env, jobject thiz, jboolean is_ok) {
    if (is_ok) {
        return is_ok;
    } else {
        return !is_ok;
    }
}
extern "C"
JNIEXPORT jchar JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeChar(JNIEnv *env, jobject thiz, jchar cha) {
    return 'd';
}
extern "C"
JNIEXPORT jdouble JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeDouble(JNIEnv *env, jobject thiz, jdouble number) {
    return number * 2.0;
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeInt(JNIEnv *env, jobject thiz, jint age) {
    char str[] = "age-------";
    printf("%s %d", str,age);
    strcat(str,str);
    return age++;
}
extern "C"
JNIEXPORT jfloat JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeFloat(JNIEnv *env, jobject thiz, jfloat score) {
    return ++score;
}extern "C"
JNIEXPORT jshort JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeShort(JNIEnv *env, jobject thiz, jshort length) {
    return --length;
}extern "C"
JNIEXPORT jlong JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeLong(JNIEnv *env, jobject thiz, jlong unix_time) {
    return unix_time--;
}extern "C"
JNIEXPORT jbyte JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeByte(JNIEnv *env, jobject thiz, jbyte by) {
    return by + 2;
}extern "C"
JNIEXPORT jbyteArray JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeBytes(JNIEnv *env, jobject thiz, jbyteArray bytes) {
    // TODO: implement getTypeBytes()
}extern "C"
JNIEXPORT jobjectArray JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeStringArray(JNIEnv *env, jobject thiz, jobjectArray strings) {
    // TODO: implement getTypeStringArray()
}extern "C"
JNIEXPORT jobject JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeList(JNIEnv *env, jobject thiz, jobject string_list) {
    // TODO: implement getTypeList()
}extern "C"
JNIEXPORT jobject JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeObject(JNIEnv *env, jobject thiz, jobject person) {
    // TODO: implement getTypeObject()
}extern "C"
JNIEXPORT jobject JNICALL
Java_com_jzqf_ndk_jni_Ndk_getTypeObjects(JNIEnv *env, jobject thiz, jobject person_list) {
    // TODO: implement getTypeObjects()
}